package com.leet.competition;

import java.lang.reflect.Array;
import java.util.Arrays;

public class KillMonster {
    public int eliminateMaximum(int[] dist, int[] speed) {
        double[] time = new double[dist.length];
        for(int i = 0 ; i < dist.length; i++){
            time[i] = (double)dist[i]/speed[i];
        }
        Arrays.sort(time);
        int cnt = 0;

        int[] map = new int[1000001];
        Arrays.fill(map,0);
        // if(time[0] < 0.01) return 0;
        for(int i = 0 ;i < time.length; i++){
            if((int)time[i] == time[i]) {
                map[(int) Math.floor(time[i])]++;
                System.out.println((time[i]));
            }
            else map[(int) Math.floor(time[i])+1]++;
        }
        int chance = 0;
        for(int i = 0 ;i < map.length; i++){
            if(map[i] == 0) chance++;
            if(map[i] == 1) cnt += 1;
            if(map[i] >= 2){
                while(chance > 0){
                    chance--;
                    map[i]--;
                    cnt++;
                    if(map[i] <= 0) break;
                }
                if(map[i] >= 1){
                    return cnt;
                }
            }
        }
        return cnt;
    }

    public static void main(String[] args) {
        int[] dist = new int[]{3,2,4};
        int[] speed = new int[]{5,3,2};
        KillMonster killMonster = new KillMonster();
        int i = killMonster.eliminateMaximum(dist, speed);
        //System.out.println(i);
    }
}
